/*************************************************************************
 Copyright (C) Unpublished Unis Software, Inc. All rights reserved.
 Unis Software, Inc., Confidential and Proprietary.

 This software is subject to copyright protection
 under the laws of the Public of China and other countries.

 Unless otherwise explicitly stated, this software is provided
 by Unis "AS IS".
 *************************************************************************/
package com.unis.web.control;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import com.unis.model.example.User;
import com.unis.service.example.UserService;

/**
 * @author CSJ (email:raulcsj@163.com)
 * @since 2012-11-10
 */
@Controller
@RequestMapping("/user")
public class UserController {
    private UserService userService;

    @RequestMapping("insert/{id}")
    public String insertUser(@PathVariable String id) {
        User user = new User();
        user.setStatmentId("User.insert");
        user.setUserId(id);
        user.setUsername("CSJ");
        user.setPassword("csj");
        userService.insert(user);
        return "hello";
    }

    @RequestMapping("delete/{id}")
    public String deleteUser(@PathVariable String id) {
        User user = new User();
        user.setStatmentId("User.delete");
        user.setUserId(id);
        userService.delete(user);
        return "hello";
    }

    @RequestMapping("update/{id}")
    public String updateUser(@PathVariable String id) {
        User user = new User();
        user.setStatmentId("User.update");
        user.setUserId(id);
        user.setUsername("Raul");
        user.setPassword("raul");
        userService.update(user);
        return "hello";
    }

    @Resource
    public void setUserService(UserService userService) {
        this.userService = userService;
    }

}
